const express = require('express');
const router = express.Router();

var db = require('../sqldb/index.js');
var email =require('../model/email.js')

/* GET home page. */
router.get('/:page', (req, res, next) => {
	res.render('content', { title: 'Express' });
});

router.post('/getContent/:num', (req, res, next) => {
	return db.sequelize.transaction(function(t){
		console.log("+++++++++++++++++++")
		return email(db.sequelize).findOne({
			where:{
				id:req.params.num
			}
		},{
			transaction:t
		}).then(function(data){
			res.json({
				status:1,
				msg:'',
				result:data
			})
		}).catch(function(err){
			res.json({
				status:0,
				msg:err,
				result:''
			})
			console.log("发生错误：" + err);
		});
	})
});

module.exports = router;
